import '../css/index.css'
import  { Component } from "react";

//定义函数组件
class child extends Component{
  state={
    title :'我是组件1'
  }
  
  dianczan = (id,title)=>( this.props.addCount(id,title))
  render(){
    return(

      <div className="parent">
      <h1>今日要闻</h1>
      { 
        this.props.newsList.map(item=>
           (
            <div className="child" key={item.id}>
              <h3>{item.content}</h3>
              <div className="detail">
                <span>{item.copyRight}</span>
                <span >{item.likeCount}点赞</span>
                <span onClick={() =>this.dianczan(item.id,this.state.title)} style={{color:'blue',cursor:'pointer'}}>点赞+1</span>
              </div>
            </div>
          )
        )
      }
    </div>
    )
  }
  
}
export default child


